<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3642：[CEOI 2014] Cake</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[CEOI 2014] Cake</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[CEOI 2014] Cake</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [CEOI 2014] Cake                </h1>
                <p>时间限制：20s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：1024MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div style="line-height: 12pt"><span style="font-size: medium">Leopold买了n块蛋糕, 这些蛋糕排成一排，从左到右记为1到n，第i块蛋糕最初的美味度为di。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">Leopold每次固定最先吃第k块蛋糕，于是位置k就空出来了。之后他吃的每一块蛋糕总是位于某个空的位置旁边，并且是美味度最低的一块。因此在任何时刻，所有空的位置是一段连续的区间。Leopold会装饰自己的蛋糕来增加它的美味度，被加过装饰的蛋糕一定会成为最美味的10个蛋糕之一，任何时候都不存在两块美味度相同的蛋糕。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">Leopold想知道在他吃到某块蛋糕b之前需要吃掉多少块蛋糕。</span></div>
<div><span style="font-size: medium">&nbsp;</span></div></p><hr/><h3>输入格式</h3><p><div style="line-height: 12pt"><span style="font-size: medium">第一行两个整数n和k，表示蛋糕的数量和Leopold吃的第一块蛋糕的位置。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">第二行n个不同的整数d1,d2...,dn，表示第i块蛋糕最初的美味度。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">第三行一个整数q，表示操作的数量。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">下面q行会包括以下两种操作。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">(1)E i e 蛋糕i被装饰成了第e美味的蛋糕（即原来前e-1美味的蛋糕不变，原来第e美味的蛋糕变成了第e+1美味的蛋糕，以此类推）注意每次装饰一定会增加美味度。</span></div>
<div style="line-height: 12pt"><span style="font-size: medium">(2)F b输出Leopold吃到蛋糕b之前需要吃掉多少块蛋糕。</span></div>
<div><span style="font-size: medium">&nbsp;</span></div></p><hr/><h3>输出格式</h3><p><div style="line-height: 12pt"><span style="font-size: medium">对于每个F操作，输出一行一个整数，表示蛋糕的数量。</span></div>
<div><span style="font-size: medium">&nbsp;</span></div></p><hr/><h3>样例输入</h3><pre>5 3
5 1 2 4 3
17
F 1
F 2
F 3
F 4
F 5
E 2 1
F 1
F 2
F 3
F 4
F 5
E 5 2
F 1
F 2
F 3
F 4
F 5
 
</pre><hr/><h3>样例输出</h3><pre>4
1
0
2
3
4
3
0
1
2
4
3
0
1
2
 
</pre><hr/><h3>提示</h3><p><p>在第一次装饰前，蛋糕会按顺序3,2,4,5,1被吃掉。但装饰以后，由于蛋糕2美味度较高，它不会很快被吃掉，而蛋糕4和5会先被吃掉。但是第二次对蛋糕5的装饰对于吃掉蛋糕的顺序没有影响。<br />
&nbsp;<br />
对于100%的数据满足<br />
1&le;k&le;n&le;250000<br />
1&le;q&le;500000<br />
1&le;e&le;10<br />
</p></p><hr/><h3>题目来源</h3><p>uploaded by dwellings</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3642" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3642" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>